package test

import ninenineqs._

/**
  * Created by wyc on 6/11/2017.
  * Eliminate consecutive duplicates of list elements.
  * If a list contains repeated elements they should be replaced with a single copy of the element. The order of the elements should not be changed.
  * Example:
  * scala> compress(List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, 'a, 'd, 'e, 'e, 'e, 'e))
  * res0: List[Symbol] = List('a, 'b, 'c, 'a, 'd, 'e)
  */

class test_p08 extends UnitSpec{
  feature(this.getClass.toString) {
    val L1 = List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, 'a, 'd, 'e, 'e, 'e, 'e)
    val L2 = List[Any]()
    val L3 = List(4)

    val Ts:List[(List[Any]) => List[Any]]=List(
      p08.compress_v1,
      p08.compress_v2,
      p08.compress_v3
    )

    var v = 1
    for ( func <- Ts ) {
      scenario("flatten_v" + v) {
        assert(func(L1) == List('a, 'b, 'c, 'a, 'd, 'e))
        assert(func(L2) == List[Any]())
        assert(func(L3) == List(4))
      }
      v += 1
    }
  }
}
